#!/usr/bin/php
<?php

function main($argc, & $argv)
{
    $db = new MySQLi('3.3.3.9', 'company', 'abc', 'company', '3306');
    if (!$db) {
        fprintf(STDERR, "connect failed!\n");
        return 1;
    }

    $result = $db->query("select * from emp");

    /*
     * $data = $result->fetch_all();
     * foreach ($data as $row) {
     *     foreach ($data as $col) {
     *         echo $col, " ";
     *     }
     *     echo PHP_EOL;
     * }
     */

    // while ($data = $result->fetch_array(MYSQLI_NUM)) {
    // while ($data = $result->fetch_row()) {
    while ($data = $result->fetch_assoc()) {
        foreach ($data as $col) {
            echo $col, " ";
        }
        echo PHP_EOL;
    }

    // print_r($data);

    // return 0;


    $db->close();

    return 0;
}

exit(main($argc, $argv));

